package com.zdsoft.blp.zongbuju.shouye.linliquan.activity;

import android.content.Intent;
import android.support.v4.app.Fragment;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.zdsoft.blp.R;
import com.zdsoft.blp.gongyong.isLoginSuccess.IsLoginSuccess;
import com.zdsoft.blp.gongyong.linliFragment.LinLiView;
import com.zdsoft.blp.gongyong.net.BaseActivity;
import com.zdsoft.blp.zongbuju.shouye.linliquan.adapter.PCfragmentAdapter;
import com.zdsoft.blp.zongbuju.shouye.linliquan.fragment.XWfragmentLeft;
import com.zdsoft.blp.zongbuju.shouye.linliquan.fragment.XWfragmentRight;

import java.util.ArrayList;
import java.util.List;

public class LLXunWuActivity extends BaseActivity {
    private LinLiView llv;          //封装的viewPager+fragment
    private TextView tv_title;      //封装的标题
    private ImageView title_bianji;//编辑图片
    public int source;
    @Override
    protected void init() {

        setContentView(R.layout.linli_pinchexinxi);
        llv = find(R.id.llv);
        //设置标题
        tv_title = find(R.id.tv_title);
        tv_title.setText("寻物招领");
        llv.getTv_left().setText("寻物");
        llv.getTv_right().setText("招领");
        Intent intent=getIntent();
        source=intent.getIntExtra("source",1);
        //图片跳转到编辑页面
        title_bianji = find(R.id.title_bianji);
        title_bianji.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (IsLoginSuccess.isloginSuccess(LLXunWuActivity.this,true)){
                    Intent intent = new Intent(LLXunWuActivity.this,FBTYActivity.class);
                    if(llv.isChack()){
                        intent.putExtra("title","寻物发布");
                        intent.putExtra("aSource","寻物");
                    }else{
                        intent.putExtra("title","招领发布");
                        intent.putExtra("aSource","招领");
                    }
                    startActivity(intent);
                }

            }
        });
        //加载fragment布局
        List<Fragment> fragments = new ArrayList<>();
        fragments.add(new XWfragmentLeft());
        fragments.add(new XWfragmentRight());
        llv.getVp().setAdapter(new PCfragmentAdapter(getSupportFragmentManager(),fragments));
    }

}
